package com.masterclient.app.businessmodule.minemodule.point.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.minemodule.point.model.PointProduct;
import com.eoner.baselibrary.utils.DensityUtil;
import com.eoner.baselibrary.utils.RoundedCornersTransform;
import com.eoner.baselibrary.utils.Utils;

/**
 * 作者：sean
 * 创建时间：2017/6/23 16:32
 * 功能说明：
 */

public class PointProductAdapter extends BaseQuickAdapter<PointProduct, BaseViewHolder> {
//    @BindView(R.id.iv_goods)
//    ImageView ivGoods;
//    @BindView(R.id.tv_new_goods_promotion)
//    TextView tvNewGoodsPromotion;
//    @BindView(R.id.tv_sub_title)
//    TextView tvSubTitle;
//    @BindView(R.id.tv_title)
//    TextView tvTitle;
//    @BindView(R.id.tv_price_now)
//    TextView tvPriceNow;
//    @BindView(R.id.tv_price_older)
//    TextView tvPriceOlder;

    public PointProductAdapter() {
        super(R.layout.point_product_item);
    }

    @Override
    protected void convert(BaseViewHolder helper,PointProduct item) {
//        App.picasso.load(item.getSh_image())
//                .resize(ScreenUtils.dp2px(165), ScreenUtils.dp2px(165))
//                .placeholder(R.mipmap.defaults).error(R.mipmap.defaults)
//                .into((ImageView) helper.getView(R.id.iv_goods));
        RoundedCornersTransform transform = new RoundedCornersTransform(mContext, DensityUtil.dip2px(7));
        transform.setNeedCorner(true, true, false, false);
        RequestOptions options = new RequestOptions().placeholder(R.mipmap.defaults).transform(transform);
        Glide.with(mContext).asBitmap().load(item.getSh_image()).apply(options).into((ImageView) helper.getView(R.id.iv_goods));

        helper.setText(R.id.tv_sub_title,item.getSh_name());
        helper.setText(R.id.tv_price_now,item.getSh_integral_price());
        Utils.setDin(helper.getView(R.id.tv_price_now),mContext);
        helper.setText(R.id.tv_price_older,"¥"+item.getSh_price());

        View ll_shouqing = helper.getView(R.id.ll_shouqing);

        TextView exchange_btn = helper.getView(R.id.exchange_btn);
        if(item.getSh_stock() != null && Long.valueOf(item.getSh_stock()) > 0){
            exchange_btn.setText("金币兑换");
            exchange_btn.setBackgroundResource(R.drawable.point_exchange_btn_bkg);
            exchange_btn.setTextColor(Color.parseColor("#FFFFFF"));
            exchange_btn.setVisibility(View.VISIBLE);
            ll_shouqing.setVisibility(View.GONE);
        }else{
            ll_shouqing.setVisibility(View.VISIBLE);
            exchange_btn.setText("已售罄");
            exchange_btn.setBackgroundResource(R.drawable.shape_point_button);
            exchange_btn.setTextColor(Color.parseColor("#66000000"));
//            exchange_btn.setVisibility(View.GONE);
        }
//        TextView tv_bofang = helper.getView(R.id.tv_bofang);
//        tv_bofang.setTypeface(Typeface.createFromAsset(mContext.getAssets(), "font/iconfont.ttf"));
//
//        ((TextView)helper.getView(R.id.tv_price_older)).setPaintFlags(Paint. STRIKE_THRU_TEXT_FLAG| Paint.ANTI_ALIAS_FLAG);
//        ImageView ivActivity = helper.getView(R.id.iv_activity);
//
//        ImageView ivTagNew = helper.getView(R.id.iv_tag_new);
//        View ivShouqing = helper.getView(R.id.ll_shouqing);
//        LinearLayout ll_user = helper.getView(R.id.ll_user);
//        LinearLayout ll_earn = helper.getView(R.id.ll_earn);
//        TextView tv_price = helper.getView(R.id.tv_price);
//        TextView tv_money_earn = helper.getView(R.id.tv_money_earn);
//
//
//        if(Integer.valueOf(item.getSh_stock())<=0){
//            ivShouqing.setVisibility(View.VISIBLE);
//        }else {
//            ivShouqing.setVisibility(View.GONE);
//        }
//        ivActivity.setVisibility(View.GONE);

    }
}
